import request from "@/utils/request";

const baseUri = "/mv1/api/article/category/";

export interface CategoryQuery extends PageQuery {
  page?: number;
  limit?: number;
  keywords?: string;
  // shop_title?: string;
}

export interface CategoryDetail {
  id: number;
  title: string;
  status: string;
  // content?: string;
}

export interface CategoryForm {
  id?: number;
  title?: string;
  // shop_id?: number;
  // shop_title?: string;
  // content?: string;
  // thumb?: string;
  // banner?: string;
  sort: number;
  status: number;
}

export function categoryList(query: CategoryQuery) {
  return request({
    url: baseUri,
    method: "get",
    params: query,
  });
}

export function categoryDetail(id: number) {
  return request({
    url: baseUri + "detail/" + id,
    method: "get",
    params: {},
  });
}

export function categoryOptions() {
  return request({
    url: baseUri + "options",
    method: "get",
  });
}

export function createCategory(data: CategoryForm) {
  return request({
    url: baseUri + "add",
    method: "post",
    data,
  });
}

export function updateCategory(id: number, data: CategoryForm) {
  return request({
    url: baseUri + "edit/" + data.id,
    method: "put",
    data,
  });
}

export function deleteCategory(id: number) {
  return request({
    url: baseUri + id,
    method: "delete",
    data: {},
  });
}
